<%-- 
    Document   : display_posts_by_type
    Created on : 2 Jun, 2012, 10:42:56 PM
    Author     : bharat
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="./css/maincss.css">
        <link rel="stylesheet" type="text/css" href="./css/myaccountcss.css">
        <title>Online College Magazine</title>
    </head>
    <body>
        <div class="container">
            <div class="header">
                ONLINE COLLEGE MAGAZINE
            </div>
            <div class="navigation_menu">
                <%@include file="navigationmenu.jsp"%>
            </div>

            <div class="slab">

                <%

                    String usrname = (String) session.getAttribute("usr");
                    String pid_ = request.getParameter("pid");

                    Connection con2 = null;
                    PreparedStatement pstmt1 = null;
                    ResultSet rs1 = null;

                    try {
                        Class.forName("oracle.jdbc.driver.OracleDriver");
                        con2 = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "aksh", "aksh");

                        pstmt1 = con2.prepareStatement("select *from posts where pid=?");
                        pstmt1.setString(1, pid_);
                        rs1 = pstmt1.executeQuery();
                %>

                <table border="2">
                    <tr class="tab">
                        <td>Type</td>
                        <td>Subject</td>
                        <td>Posted on</td>
                    </tr>

                    <%
                        while (rs1.next()) {
                    %>

                    <tr>
                        <td><%=rs1.getString(3)%></td>
                        <td><%=rs1.getString(4)%></td>
                        <td><%=rs1.getString(5)%></td>
                    </tr>
                    <%                    }
                    %>
                </table>
                <%

                    } catch (Exception e) {
                        response.sendError(503, e.getMessage());
                    } finally {
                        if (rs1 != null) {
                            try {
                                rs1.close();
                            } catch (Exception e) {
                                response.sendError(555, e.getMessage());
                            }
                        }
                        if (pstmt1 != null) {
                            try {
                                pstmt1.close();
                            } catch (Exception e) {
                                response.sendError(555, e.getMessage());
                            }
                        }
                        if (con2 != null) {
                            try {
                                con2.close();
                            } catch (Exception e) {
                                response.sendError(555, e.getMessage());
                            }
                        }
                    }

                %>

            </div>

            <div class="login">
                <%@include file="types_anchored.html" %>
            </div>

            <div class="sidebar">
                <%@include file="archives_sidebar.jsp"%>
            </div>

            <div class="footer">
                FOOTER
            </div>
        </div>
    </body>
</html>

